package com.onileVideo.content.api;

import com.onileVideo.base.model.dto.pageParams;
import com.onileVideo.base.model.dto.pageResult;
import com.onileVideo.content.model.dto.AddCourseDto;
import com.onileVideo.content.model.dto.CategoryDto;
import com.onileVideo.content.model.dto.CourseInfoResult;
import com.onileVideo.content.model.dto.QueryCourseParamsDto;
import com.onileVideo.content.model.po.CourseBase;
import com.onileVideo.content.service.CourseBaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 课程基本信息 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
@Api(value = "课程查询接口", tags = "课程查询接口")
//@RequestMapping("courseBase")
public class CourseBaseController {

    @Resource
    private CourseBaseService courseBaseService;

    //分页查询所有课程(会有条件)
    @ApiOperation("分页查询课程数据")
    @PostMapping("/course/list")
    public pageResult<CourseBase> list(@RequestBody(required = false) QueryCourseParamsDto queryCourseParamsDto, pageParams pageParams){
        return courseBaseService.list(queryCourseParamsDto, pageParams);
    }

    @ApiOperation("课程分类查询")
    @GetMapping("/course-category/tree-nodes")
    public List<CategoryDto> queryBaseCategory(){
        return courseBaseService.queryBaseCategory();
    }

    @ApiOperation("新增课程信息")
    @PostMapping("/course")
    public CourseInfoResult insertCourse(@RequestBody AddCourseDto addCourseDto){
        Long companyId = 1L;
        return courseBaseService.insertCourse(companyId, addCourseDto);
    }

    @ApiOperation("编辑课程")
    @GetMapping("/course/{id}")
    public  CourseInfoResult editCourse(@PathVariable("id") Integer id){
        Long companyId = 1L;
        return courseBaseService.selectCourseById(id);
    }


}
